;
(function() {
	var BusCon = require("../../core/bus/_con");
	var db = require("../../core/db/index");
	var config = require("../../core/_include/config");
	var ResponObj = require("../_include/responObj");
	var BuffCon = require("../../core/buff/_con");
	var myfs = require("../_include/fs");
	var theme = require("./theme");
	var role = require("./role");
	module.exports = {
		prefix: "/user/bus_user",
		get: {
			"/": function() {
				var user = role.getUser(this);
				var query = this.request.query;
				var result = user.getBusUser_List(query.num, query.page);
				this.body = ResponObj("json", result);
			},
			"/by_bus_id": function() {
				var user = role.getUser(this);
				var query = this.request.query;
				var bus_id = query.bus_id;
				if (!bus_id) {
					throwCusError("参数错误")
				}
				var result = user.getBusUser_by_busId(query.bus_id);
				this.body = ResponObj("json", result);
			}
		},
		put: {
			"/state/未申请兑换_to_申请兑换中": function() {
				var user = role.getUser(this);
				var body = this.request.body
				var bus_id = body.bus_id;
				var money = body.money;
				if (!bus_id) {
					throwCusError("参数错误")
				}
				var bus_user = user.bus_user_state_未申请兑换_to_申请兑换中(bus_id, money);
				this.body = ResponObj("json", bus_user);
			},
			"/state/申请兑换中_to_未申请兑换":function(){
				var user = role.getUser(this);
				var body = this.request.body
				var bus_id = body.bus_id;
				if (!bus_id) {
					throwCusError("参数错误")
				}
				var bus_user = user.bus_user_state_申请兑换中_to_未申请兑换(bus_id);
				this.body = ResponObj("json", bus_user);
			},
			"/state/商家已经打款_to_用户确认收款": function() {
				var user = role.getUser(this);
				var bus_id = this.request.body.bus_id;
				if (!bus_id) {
					throwCusError("参数错误")
				}
				var bus_user = user.bus_user_state_商家已经打款_to_用户确认收款(bus_id);
				this.body = ResponObj("json", bus_user);
			}
		}
	}
}());